var updatePwd = "/profile/updatePwd"
$(function () {
    var updateValidation = $("#profilePwdForm").validate({
        rules: {
            oldPwd: {required: true},
            newPwd: {required: true, minlength: 8},
            savePwd: {required: true, minlength: 8, equalTo: "#newPwd"}
        }
    });
    $("#profilePwdForm").ajaxForm({
        target: '#btn-pwd-save',   // target element(s) to be updated with server response
        dataType: 'json',
        url: updatePwd,
        beforeSubmit: function (formData, jqForm, options) {
            return updateValidation.valid();
        },
        success: function (result, statusText, xhr, $form) {
            if (result.code != "0000") {
                showMessage(result.code || result.desc, "error");
            } else {
                window.location.href = "/index.html";
            }
        }
    });
})